<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml" id="teacherForm">
<head>
    <title>学年设定</title>
    <script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";

    $(function (){
    	
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        //如果是修改视图,主键不可编辑
        if(viewType=="modify"){
        	 $("#hpqId").attr("readonly", "readonly").removeAttr("validate");
        }
        
        //如果是详细试图,所有字段不可编辑
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);

    });
   
    function save(){
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + result.message);
            }else {
                LG.showSuccess('保存成功', function () { 
                	saveSuccess();
                });
            }
        });
        
    }
    
    function saveSuccess(){
        var win = window.parent || window;
        if(win.askQuestionSuccess){
        	win.askQuestionSuccess();
        }
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
 </script>
</head>

<body>
    <form name="mainform" method="post"  id="mainform" action="${ctx }/qso/helpque/save" enctype=”multipart/form-data”>
        <input type="hidden" name="viewType" value="${viewType}"/>
        <input type="hidden" name="hpqId" value="${command.hpqId}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 90%; margin-top:10px; margin-left:15px;">                 
			<tr>
                <td align="right" class="l-table-edit-td" style="width:15%">问题:</td>
                <td align="left" class="l-table-edit-td" colspan="3"> 
                	<textarea cols="60" rows="3" class="l-textarea" id="hpqQuestion" name="hpqQuestion" style="width:88%;">${command.hpqQuestion}</textarea>
				</td>
			</tr>
			<tr>
                <td align="right" class="l-table-edit-td" style="width:15%">附件:</td>
                <td align="left" class="l-table-edit-td" colspan="3"> 
                	<input type="file" name="file"/>
				</td>
			</tr>
        </table>
    </form>
</body>
</html>

